package com.icoopoo.utils.resultResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @部门:icoopoo
 * @功能:略
 * @描述:略
 * @作成者:icoopoo 
 * @Data:2018年11月29日 下午9:35:03
 * json 返回包装类
 */
public class HelperResponse {
	
	private static String resultCode = "0";
	
	private static String resultMsg = "";
	
	public static Map<String,Object> successMap(Map<Object,Object> data){
		Map<String,Object> headMap = new HashMap<String,Object>();
		headMap.put("resultCode", resultCode);
		headMap.put("resultMsg", resultMsg);
		Map<String,Object> resultMap = new HashMap<String, Object>();
		resultMap.put("head", headMap);
		resultMap.put("body", data);
		resultCode = "0";
		resultMsg = "";
		return resultMap;
	}
	
	public static Map<String,Object> errorMap(String msg){
		resultCode = "1";
		resultMsg = "";
		Map<String,Object> resultMap = successMap(null);
		return resultMap;
	}
	
	public static Map<String,Object> successObject(Object data){
		Map<String,Object> headMap = new HashMap<String,Object>();
		headMap.put("resultCode", resultCode);
		headMap.put("resultMsg", resultMsg);
		Map<String,Object> resultMap = new HashMap<String, Object>();
		resultMap.put("head", headMap);
		resultMap.put("body", data);
		resultCode = "0";
		resultMsg = "";
		return resultMap;
	}
	
	public static Map<String,Object> errorObject(String msg){
		resultCode = "1";
		resultMsg = "";
		Map<String,Object> resultMap = successObject(null);
		return resultMap;
	}
	
}
